home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / allocwg.com / REDUCEDD.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-10  |  2.4 KB  |  85 lines

  1. #ifndef MSC
  2.  
  3.     /*  Non-MSC Version  */
  4.  
  5. #if (defined(M_I86CM) || defined(M_I86LM) || defined(M_I86HM))
  6.  
  7.     /*  NOTE:  These procedures should only be used for
  8.                large data model programs (i.e., Compact, Large, Huge) */
  9.  
  10. #include <stddef.h>
  11. #include "alloc.h"
  12.  
  13. int ReduceDefaultData ()
  14.  
  15. /*
  16.          +---------------------------------------+
  17.          |                                       |  
  18.          |  This procedure reduces the default   |  
  19.          |  data segment to it's minimum size.   |  
  20.          |  It should be called prior to doing   |  
  21.          |  any memory allocation through malloc |  
  22.          |  or calloc, etc.  Normally, the MSC   |  
  23.          |  linker allocates 0xffff bytes to     |  
  24.          |  this segment even though only a      |  
  25.          |  lesser amount is actually used. This |  
  26.          |  procedure has the same effect as     |  
  27.          |  setting the maximum paragraph size   |  
  28.          |  to the minimum paragraph size via    |  
  29.          |  exemod.                              |  
  30.          |                                       |  
  31.          +---------------------------------------+
  32. */
  33.  
  34. {
  35.    extern size_t   _abrktb [] ;
  36.    extern size_t   _asizds    ;
  37.    extern size_t   _psp       ;
  38.    size_t   maxsize           ;
  39.    size_t   newsize           ;
  40.    size_t   para              ;
  41.    size_t   error             ;
  42.  
  43.    newsize = NALLOC * ((_abrktb [0] - 1)/NALLOC + 1) ;
  44.    para    = newsize / NALLOC + _abrktb [1] - _psp  ; 
  45.    error   = _dos_setblock ( para, _psp, &maxsize ) ;
  46.    if ( error != 0 )
  47.       return ( FALSE ) ;
  48.  
  49.    _asizds = newsize  ;
  50.    return ( TRUE ) ;
  51. }
  52.  
  53. void near *_nmalloc ( nbytes )
  54.  
  55.    size_t       nbytes ;
  56.  
  57. /*
  58.          +---------------------------------------+
  59.          |                                       |  
  60.          |  Dummy for _nmalloc using large data  |  
  61.          |                                       |  
  62.          +---------------------------------------+
  63. */
  64.  
  65. {
  66.    return ( (void near *) NULL ) ;
  67. }
  68.  
  69. void _nfree ( ap )
  70.  
  71.    void near *ap  ;
  72.  
  73. /*
  74.          +---------------------------------------+
  75.          |                                       |  
  76.          |  Dummy for _nfree  (large data)       |  
  77.          |                                       |  
  78.          +---------------------------------------+
  79. */
  80.  
  81. {
  82. }
  83. #endif
  84. #endif
  85.